<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
		StringBuffer errorString=new StringBuffer("");
		if (request.getParameter("tk") != null)
		{
			errorString.append("奖品名称不能为空！\\n");
		}
		if (request.getParameter("sl") != null)
		{
			errorString.append("图片应该小于3M！ \\n");
		}
		if (request.getParameter("f") != null)
		{
			errorString.append("上次图片格式不正确！\\n ");
		}
		if (request.getParameter("un") != null)
		{
			errorString.append("添加失败！ \\n");
		}	
		if (request.getParameter("exs") != null)
		{
			errorString.append("已存在相同名称奖品！\\n");
		}
		if (request.getParameter("ok") != null)
		{
			errorString.append("添加成功！\\n");
		}
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">

		<title>添加奖品</title>
		<link href="css/gl/tjjp.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="script/jquery/jquery-1.5.1.min.js" ></script>
<script type="text/javascript">
//添加通告
function AddAward(){
	var title = $("#title").val();
	var remark = $("#remark").val();
	var imgfile = $("#imgfile").val();
	var hasimg = $("#hasimg").attr("checked");
	if(title.length<1){
		alert("奖品名称不能为空！");
		return false;
	}else if(title.length>50){
		alert("奖品名称字数应小于50！");
		return false;
	}
	if(imgfile.length>4){//说明上传了音频文件
		
	    if(imgfile.lastIndexOf(".")==-1)
	    {
	         alert("上传图片格式不正确！");
       		 return false;
	    }
	    var ext=imgfile.substring(imgfile.lastIndexOf(".")+1).toLowerCase();
		if(ext=="gif" || ext=="jpg" || ext=="png") {
			
         }
        else{
        	 alert("只允许上次gif,jpg,png格式的图片！");
	       		return false;
         }
	 }
	 //else{
	//	alert("请选择要上传的图片！");	
	//	return false;
	// }
	document.addNotice.submit();
}
function error()
{ 
	if("<%=errorString.toString()%>".length>0)
	{
	 alert("<%=errorString.toString()%>");
	}
}
$(function() {
	error();
});
</script>
	</head>

	<body>
		<form name="addNotice" method="post" enctype="multipart/form-data"
			action="gl/addAward.do">
			<div id="page_all">
				<jsp:include page="title.jsp" flush="true">
					<jsp:param name="jspName" value="khModuleOpt" />
				</jsp:include>
				<div id="main">
					<div id="tgleft">
						<jsp:include page="khleft.jsp" flush="true">
							<jsp:param name="jspName" value="tjjp" />
						</jsp:include>
					</div>
					<div id="tgmain">
						<table id="addnotice" cellpadding="0" cellspacing="0">
							<tr>
								<td class="ftd">
									奖品名称:
								</td>
								<td>
									<input id="title" name="title" maxlength="50">
								</td>
							</tr>
							<tr>
								<td class="ftd" style="vertical-align: top;">
									备注:
								</td>
								<td style="padding-top:5px; ">
									<input id="remark" name="remark" maxlength="100">
								</td>
							</tr>
							<tr>
								<td class="ftd" style="padding-top:5px; ">
									图片:
								</td>
								<td style="padding-top:5px; ">
									<input id="imgfile" name="imgfile" type="file" style="height:21px;">
								</td>
							</tr>
							<tr>
								<td class="ftd">
									等级:
								</td>
								<td style="padding-top:8px; ">
									<select id="kind" name="kind">
										<option value="1">
											一等奖
										</option>
										<option value="2">
											二等奖
										</option>
										<option value="3">
											三等奖
										</option>
									</select>
								</td>
							</tr>
						</table>
						<div class="bunpanel" style="">
							<img alt="" style="cursor: pointer;" src="img/gl/addbtn.jpg"
								onclick="AddAward()" />
						</div>
					</div>

				</div>
				<div id="footer">
					<jsp:include page="footer.jsp" flush="true"></jsp:include>
				</div>
			</div>
		</form>
	</body>
</html>
